/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#include "param_impl.h"

#include "atc.h"

using namespace atc;


//------------------------------------------------------------------------------
// Construction / Destruction
//

/*!
 * Default Constructor.
 */
ParamImpl::ParamImpl()
	:_rate(CLOCK_TICK_PERIOD)
	,m_acAcceptanceType(ACCEPTANCE_MANUAL)
	,_multiplier(CLOCK_TICK_XFACTOR)
	,_format("")
	,_hdoms(5)
	,_vdoms(0)
	,_conflictColour()
	,_palette()
	,_selectTools()
	,_srprobe(0)
	,_score(0)
	,_scalePosition( TOPLEFT )
	,_infoPos( TOPLEFT )
	,_infoBlk()
	,m_conflictDeclarationScoreEnabled(true)
	,m_conflictDeclarationAudioEnabled(true)
	,m_conflictDeclarationSpeedChange(false)
	,m_conflictDeclarationLevelChange(true)
{
	// Set default colours
//	for ( ControlState s = MIN; s < MAX; s = ControlState(s+1) ) {
//		_palette[ s ] = Colour();
//	}
}

/*!
 * Destructor
 */
ParamImpl::~ParamImpl()
{}


//--------------------------------------------------------------------------------------------------
// Param interface (mutator methods)
//

void ParamImpl::set_update_rate( unsigned int rate ) { _rate = rate; }

void ParamImpl::set_update_multiplier( float multiplier ) { _multiplier = multiplier; }

void ParamImpl::set_counter_format( const char *format ) { _format = format; }

void ParamImpl::set_hdoms( int doms ) { _hdoms = doms; }

void ParamImpl::set_vdoms( int doms ) { _vdoms = doms; }

void ParamImpl::set_conflict_colour( QColor color, bool is_blinking ) {
	_conflictColour.colour = color;
	_conflictColour.blink = is_blinking;
}

void ParamImpl::set_cs_colour( 
		ControlState cs, 
		QColor color, 
		bool is_blinking 
) {
	_palette[ cs ] = Colour( color, is_blinking );
}


void ParamImpl::set_scale_tool( const ToolParams &params )    { 
	_selectTools[ CanvasItem::RTTI_SCALE ]    = params; 
}

void ParamImpl::set_altitude_tool( const ToolParams &params ) { 
	_selectTools[ CanvasItem::RTTI_ALTBLK ] = params; 
}

void ParamImpl::set_airspeed_tool( const ToolParams &params ) { 
	_selectTools[ CanvasItem::RTTI_VELBLK ] = params; 
}


void ParamImpl::set_keyed_tool( int key, CanvasItem::TOOL tool, std::string tag ) {
	_toolSet.insert( tool );
	_keyTool[ key ] = tool;
	_keyTag[ key ] = tag;
}

void 
ParamImpl::SetAircraftDeclarationText(	unsigned int a_row, 
										const std::string& a_value)
{
	AircraftDeclarationText text(a_row, a_value);

	m_aircraftDeclaration.m_texts.push_back(text);
}

void 
ParamImpl::SetAircraftDeclarationButton(	const std::string& a_name, 
											const std::string& a_type, 
											const std::string& a_label)
{
	AircraftDeclarationButton button (a_name, a_type, a_label);

	m_aircraftDeclaration.m_buttons.push_back(button);
}
//--------------------------------------------------------------------------------------------------
